\hypertarget{fill_8c}{}\doxysubsection{extern/libembroidery/src/fill.c File Reference}
\label{fill_8c}\index{extern/libembroidery/src/fill.c@{extern/libembroidery/src/fill.c}}
{\ttfamily \#include $<$stdio.\+h$>$}\newline
{\ttfamily \#include $<$stdlib.\+h$>$}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$math.\+h$>$}\newline
{\ttfamily \#include \char`\"{}embroidery\+\_\+internal.\+h\char`\"{}}\newline
\doxysubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \mbox{\hyperlink{fill_8c_af27a83a237ef6302cbfb5af534229e10}{lindenmayer\+\_\+system}} (\mbox{\hyperlink{embroidery_8h_a914404401c03a6bf0dac814661ba370c}{L\+\_\+system}} L, char $\ast$state, int iterations, int complete)
\item 
static void \mbox{\hyperlink{fill_8c_a0fd47c53d468e3e5590e096495acac79}{join\+\_\+short\+\_\+stitches}} (int $\ast$points, int $\ast$n\+\_\+points, int width, int tolerence)
\item 
static int $\ast$ \mbox{\hyperlink{fill_8c_adc8683886c723530102d2b75f14b6dbd}{threshold\+\_\+method}} (\mbox{\hyperlink{embroidery_8h_a907d23c2268eff84b7c5146b2add1bb4}{Emb\+Image}} $\ast$image, int $\ast$n\+\_\+points, int subsample\+\_\+width, int subsample\+\_\+height, int threshold)
\item 
static void \mbox{\hyperlink{fill_8c_a5d43a4168ef00fcb9221321b4508c8c5}{greedy\+\_\+algorithm}} (int $\ast$points, int n\+\_\+points, int width, \mbox{\hyperlink{embroidery_8h_a2082be9aabfb541dff1825c4ca6a05cd}{Emb\+Real}} bias)
\item 
static void \mbox{\hyperlink{fill_8c_af65a5f7a682322a9588066dfc9d3e10d}{save\+\_\+points\+\_\+to\+\_\+pattern}} (\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$pattern, int $\ast$points, int n\+\_\+points, \mbox{\hyperlink{embroidery_8h_a2082be9aabfb541dff1825c4ca6a05cd}{Emb\+Real}} scale, int width, int height)
\item 
void \mbox{\hyperlink{fill_8c_a51526002a19f07437ee07f4c6d475690}{emb\+Pattern\+\_\+horizontal\+\_\+fill}} (\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$pattern, \mbox{\hyperlink{embroidery_8h_a907d23c2268eff84b7c5146b2add1bb4}{Emb\+Image}} $\ast$image, int threshhold)
\item 
void \mbox{\hyperlink{fill_8c_aadaaf644936dbeeb4286a00c4fe04794}{emb\+Pattern\+\_\+crossstitch}} (\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$pattern, \mbox{\hyperlink{embroidery_8h_a907d23c2268eff84b7c5146b2add1bb4}{Emb\+Image}} $\ast$image, int threshhold)
\item 
int \mbox{\hyperlink{fill_8c_a2f0cd5118998e9310252de0bd11c6fb2}{hilbert\+\_\+curve}} (\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$pattern, int iterations)
\item 
void \mbox{\hyperlink{fill_8c_ad02b5d945eacff708d2bf084c40044d8}{generate\+\_\+dragon\+\_\+curve}} (char $\ast$state, int iterations)
\item 
int \mbox{\hyperlink{fill_8c_a9f15f9548d56044f41aa91dd103c3914}{dragon\+\_\+curve}} (int iterations)
\item 
void \mbox{\hyperlink{fill_8c_accb8d958755abb87ae8fe5cb64241c5b}{emb\+Polygon\+\_\+reduce\+By\+Distance}} (\mbox{\hyperlink{embroidery_8h_aebe8b1561a59d167cfe6613863a671ca}{Emb\+Array}} $\ast$vertices, \mbox{\hyperlink{embroidery_8h_aebe8b1561a59d167cfe6613863a671ca}{Emb\+Array}} $\ast$simplified, float distance)
\item 
void \mbox{\hyperlink{fill_8c_aa25158aa39b36f6981756295d6601910}{emb\+Polygon\+\_\+reduce\+By\+Nth}} (\mbox{\hyperlink{embroidery_8h_aebe8b1561a59d167cfe6613863a671ca}{Emb\+Array}} $\ast$vertices, \mbox{\hyperlink{embroidery_8h_aebe8b1561a59d167cfe6613863a671ca}{Emb\+Array}} $\ast$out, int nth)
\item 
\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$ \mbox{\hyperlink{fill_8c_aa629adadc7956aab2bfd8b0de7ccdd54}{emb\+Pattern\+\_\+combine}} (\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$p1, \mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$p2)
\item 
void \mbox{\hyperlink{fill_8c_a8e048d8296a5178c1188ca70ee2256e7}{emb\+Pattern\+\_\+stitch\+Arc}} (\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$p, \mbox{\hyperlink{embroidery_8h_a09945e6e919629c5787e61582c712ba1}{Emb\+Arc}} arc, int thread\+\_\+index, int style)
\item 
void \mbox{\hyperlink{fill_8c_a4927287166f2a0abbc7b482ff4054a5e}{emb\+Pattern\+\_\+stitch\+Circle}} (\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$p, \mbox{\hyperlink{embroidery_8h_a87fc13ccd4dbaa7de7c85efde17bba0e}{Emb\+Circle}} circle, int thread\+\_\+index, int style)
\item 
void \mbox{\hyperlink{fill_8c_a63bc84e4406e59c092a2e076afedf930}{emb\+Pattern\+\_\+stitch\+Ellipse}} (\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$p, \mbox{\hyperlink{embroidery_8h_a4e48ebde5bd4d82b875f98b347bdd62c}{Emb\+Ellipse}} ellipse, int thread\+\_\+index, int style)
\item 
void \mbox{\hyperlink{fill_8c_a736fce5df010bbe74ea9ad2857be9bf4}{emb\+Pattern\+\_\+stitch\+Path}} (\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$p, \mbox{\hyperlink{embroidery_8h_af29045dfeebafdcb66d114b390c4a686}{Emb\+Path}} path, int thread\+\_\+index, int style)
\item 
void \mbox{\hyperlink{fill_8c_a86f903495c0da7514294200680bd6414}{emb\+Pattern\+\_\+stitch\+Polygon}} (\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$p, \mbox{\hyperlink{embroidery_8h_a2d6988a5f4ba24d26c7eff65dbc9d029}{Emb\+Polygon}} polygon, int thread\+\_\+index, int style)
\item 
void \mbox{\hyperlink{fill_8c_a9ae9d5d7dfbb2ab361dc37970b7eb2f2}{emb\+Pattern\+\_\+stitch\+Polyline}} (\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$p, \mbox{\hyperlink{embroidery_8h_ab5563c868d8f8174d5be764808a647dd}{Emb\+Polyline}} polyline, int thread\+\_\+index, int style)
\item 
void \mbox{\hyperlink{fill_8c_ae38ddde615726bba5070a6b17ce6d018}{emb\+Pattern\+\_\+stitch\+Rect}} (\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$p, \mbox{\hyperlink{embroidery_8h_ac2f33b151fc40a0da3b14379aa0ec653}{Emb\+Rect}} rect, int thread\+\_\+index, int style)
\item 
void \mbox{\hyperlink{fill_8c_a908f6c41318183bcfceebdd9b646dc90}{emb\+Pattern\+\_\+stitch\+Text}} (\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$p, \mbox{\hyperlink{embroidery_8h_ac2f33b151fc40a0da3b14379aa0ec653}{Emb\+Rect}} rect, int thread\+\_\+index, int style)
\item 
void \mbox{\hyperlink{fill_8c_ad948b1ae6e42c31b1a020348bedddfab}{emb\+Pattern\+\_\+convert\+Geometry}} (\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$p)
\end{DoxyCompactItemize}
\doxysubsubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
const char $\ast$ \mbox{\hyperlink{fill_8c_add6424b0861a4e44ac11fc4cbf99d1d1}{rules}} \mbox{[}$\,$\mbox{]} = \{\char`\"{}+BF-\/AFA-\/FB+\char`\"{}, \char`\"{}-\/AF+BFB+FA-\/\char`\"{}\}
\item 
\mbox{\hyperlink{embroidery_8h_a914404401c03a6bf0dac814661ba370c}{L\+\_\+system}} \mbox{\hyperlink{fill_8c_a6e10b231de6baafee918b26f004d7327}{hilbert\+\_\+curve\+\_\+l\+\_\+system}}
\end{DoxyCompactItemize}


\doxysubsubsection{Function Documentation}
\mbox{\Hypertarget{fill_8c_a9f15f9548d56044f41aa91dd103c3914}\label{fill_8c_a9f15f9548d56044f41aa91dd103c3914}} 
\index{fill.c@{fill.c}!dragon\_curve@{dragon\_curve}}
\index{dragon\_curve@{dragon\_curve}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{dragon\_curve()}{dragon\_curve()}}
{\footnotesize\ttfamily int dragon\+\_\+curve (\begin{DoxyParamCaption}\item[{int}]{iterations }\end{DoxyParamCaption})}

Create the dragon curve for {\itshape iterations}.

Returns 0 if the number of iterations is greater than 10 and 1 otherwise. \mbox{\Hypertarget{fill_8c_aa629adadc7956aab2bfd8b0de7ccdd54}\label{fill_8c_aa629adadc7956aab2bfd8b0de7ccdd54}} 
\index{fill.c@{fill.c}!embPattern\_combine@{embPattern\_combine}}
\index{embPattern\_combine@{embPattern\_combine}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{embPattern\_combine()}{embPattern\_combine()}}
{\footnotesize\ttfamily \mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$ emb\+Pattern\+\_\+combine (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$}]{p1,  }\item[{\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$}]{p2 }\end{DoxyParamCaption})}

{\itshape p1} {\itshape p2} \begin{DoxyReturn}{Returns}
Emb\+Pattern$\ast$ 
\end{DoxyReturn}
\mbox{\Hypertarget{fill_8c_ad948b1ae6e42c31b1a020348bedddfab}\label{fill_8c_ad948b1ae6e42c31b1a020348bedddfab}} 
\index{fill.c@{fill.c}!embPattern\_convertGeometry@{embPattern\_convertGeometry}}
\index{embPattern\_convertGeometry@{embPattern\_convertGeometry}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{embPattern\_convertGeometry()}{embPattern\_convertGeometry()}}
{\footnotesize\ttfamily void emb\+Pattern\+\_\+convert\+Geometry (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$}]{p }\end{DoxyParamCaption})}

{\itshape p} \mbox{\Hypertarget{fill_8c_aadaaf644936dbeeb4286a00c4fe04794}\label{fill_8c_aadaaf644936dbeeb4286a00c4fe04794}} 
\index{fill.c@{fill.c}!embPattern\_crossstitch@{embPattern\_crossstitch}}
\index{embPattern\_crossstitch@{embPattern\_crossstitch}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{embPattern\_crossstitch()}{embPattern\_crossstitch()}}
{\footnotesize\ttfamily void emb\+Pattern\+\_\+crossstitch (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$}]{pattern,  }\item[{\mbox{\hyperlink{embroidery_8h_a907d23c2268eff84b7c5146b2add1bb4}{Emb\+Image}} $\ast$}]{image,  }\item[{int}]{threshhold }\end{DoxyParamCaption})}

{\itshape pattern} {\itshape image} {\itshape threshhold} 

Uses a threshhold method to determine where to put crosses in the fill.

To improve this, we can remove the vertical stitches when two crosses neighbour. Currently the simple way to do this is to chain crosses that are neighbours exactly one ahead. \mbox{\Hypertarget{fill_8c_a51526002a19f07437ee07f4c6d475690}\label{fill_8c_a51526002a19f07437ee07f4c6d475690}} 
\index{fill.c@{fill.c}!embPattern\_horizontal\_fill@{embPattern\_horizontal\_fill}}
\index{embPattern\_horizontal\_fill@{embPattern\_horizontal\_fill}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{embPattern\_horizontal\_fill()}{embPattern\_horizontal\_fill()}}
{\footnotesize\ttfamily void emb\+Pattern\+\_\+horizontal\+\_\+fill (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$}]{pattern,  }\item[{\mbox{\hyperlink{embroidery_8h_a907d23c2268eff84b7c5146b2add1bb4}{Emb\+Image}} $\ast$}]{image,  }\item[{int}]{threshhold }\end{DoxyParamCaption})}

{\itshape pattern} {\itshape image} {\itshape threshhold} 

Uses a threshhold method to determine where to put lines in the fill.

Needs to pass a \char`\"{}donut test\char`\"{}, i.\+e. an image with black pixels where\+: 10 \texorpdfstring{$<$}{<} x$\ast$x + y$\ast$y \texorpdfstring{$<$}{<} 20 over the area (-\/30, 30) x (-\/30, 30).

Use render then image difference to see how well it passes. \mbox{\Hypertarget{fill_8c_a8e048d8296a5178c1188ca70ee2256e7}\label{fill_8c_a8e048d8296a5178c1188ca70ee2256e7}} 
\index{fill.c@{fill.c}!embPattern\_stitchArc@{embPattern\_stitchArc}}
\index{embPattern\_stitchArc@{embPattern\_stitchArc}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{embPattern\_stitchArc()}{embPattern\_stitchArc()}}
{\footnotesize\ttfamily void emb\+Pattern\+\_\+stitch\+Arc (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$}]{p,  }\item[{\mbox{\hyperlink{embroidery_8h_a09945e6e919629c5787e61582c712ba1}{Emb\+Arc}}}]{arc,  }\item[{int}]{thread\+\_\+index,  }\item[{int}]{style }\end{DoxyParamCaption})}

{\itshape p} {\itshape arc} {\itshape thread\+\_\+index} {\itshape style} \mbox{\Hypertarget{fill_8c_a4927287166f2a0abbc7b482ff4054a5e}\label{fill_8c_a4927287166f2a0abbc7b482ff4054a5e}} 
\index{fill.c@{fill.c}!embPattern\_stitchCircle@{embPattern\_stitchCircle}}
\index{embPattern\_stitchCircle@{embPattern\_stitchCircle}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{embPattern\_stitchCircle()}{embPattern\_stitchCircle()}}
{\footnotesize\ttfamily void emb\+Pattern\+\_\+stitch\+Circle (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$}]{p,  }\item[{\mbox{\hyperlink{embroidery_8h_a87fc13ccd4dbaa7de7c85efde17bba0e}{Emb\+Circle}}}]{circle,  }\item[{int}]{thread\+\_\+index,  }\item[{int}]{style }\end{DoxyParamCaption})}

{\itshape p} {\itshape circle} {\itshape thread\+\_\+index} {\itshape style} 

style determines\+: stitch density fill pattern outline or fill

For now it\textquotesingle{}s a straight fill of 1000 stitches of the whole object by default.

Consider the intersection of a line in direction \char`\"{}d\char`\"{} that passes through the disc with center \char`\"{}c\char`\"{}, radius \char`\"{}r\char`\"{}. The start and end points are\+: \begin{DoxyVerb}$(c-r(d/|d|), c + r(d/|d|))$
\end{DoxyVerb}
 Lines that are above and below this with an even seperation \$s\$ can be found by taking the point on the line to be c+sn where the \$n\$ is the unit normal vector to \$d\$ and the vector to be \$d\$ again. The intersection points are therefore a right angled triangle, with one side r, another s and the third the length to be solved, by Pythagoras we have\+:

\$(c + sn -\/ \textbackslash{}sqrt\{r$^\wedge$2-\/s$^\wedge$2\}(d/$\vert$d$\vert$), c + sn + \textbackslash{}sqrt\{r$^\wedge$2-\/s$^\wedge$2\}(d/$\vert$d$\vert$))\$

repeating this process gives us all the end points and the fill only alters these lines by splitting the ones longer than some tolerence. \mbox{\Hypertarget{fill_8c_a63bc84e4406e59c092a2e076afedf930}\label{fill_8c_a63bc84e4406e59c092a2e076afedf930}} 
\index{fill.c@{fill.c}!embPattern\_stitchEllipse@{embPattern\_stitchEllipse}}
\index{embPattern\_stitchEllipse@{embPattern\_stitchEllipse}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{embPattern\_stitchEllipse()}{embPattern\_stitchEllipse()}}
{\footnotesize\ttfamily void emb\+Pattern\+\_\+stitch\+Ellipse (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$}]{p,  }\item[{\mbox{\hyperlink{embroidery_8h_a4e48ebde5bd4d82b875f98b347bdd62c}{Emb\+Ellipse}}}]{ellipse,  }\item[{int}]{thread\+\_\+index,  }\item[{int}]{style }\end{DoxyParamCaption})}

{\itshape p} {\itshape ellipse} {\itshape thread\+\_\+index} {\itshape style} 

\begin{DoxyRefDesc}{Todo}
\item[\mbox{\hyperlink{todo__todo000221}{Todo}}]finish stitch\+Ellipse \end{DoxyRefDesc}
\mbox{\Hypertarget{fill_8c_a736fce5df010bbe74ea9ad2857be9bf4}\label{fill_8c_a736fce5df010bbe74ea9ad2857be9bf4}} 
\index{fill.c@{fill.c}!embPattern\_stitchPath@{embPattern\_stitchPath}}
\index{embPattern\_stitchPath@{embPattern\_stitchPath}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{embPattern\_stitchPath()}{embPattern\_stitchPath()}}
{\footnotesize\ttfamily void emb\+Pattern\+\_\+stitch\+Path (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$}]{p,  }\item[{\mbox{\hyperlink{embroidery_8h_af29045dfeebafdcb66d114b390c4a686}{Emb\+Path}}}]{path,  }\item[{int}]{thread\+\_\+index,  }\item[{int}]{style }\end{DoxyParamCaption})}

{\itshape p} {\itshape rect} {\itshape thread\+\_\+index} {\itshape style} 

\begin{DoxyRefDesc}{Todo}
\item[\mbox{\hyperlink{todo__todo000222}{Todo}}]finish stitch path \end{DoxyRefDesc}
\mbox{\Hypertarget{fill_8c_a86f903495c0da7514294200680bd6414}\label{fill_8c_a86f903495c0da7514294200680bd6414}} 
\index{fill.c@{fill.c}!embPattern\_stitchPolygon@{embPattern\_stitchPolygon}}
\index{embPattern\_stitchPolygon@{embPattern\_stitchPolygon}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{embPattern\_stitchPolygon()}{embPattern\_stitchPolygon()}}
{\footnotesize\ttfamily void emb\+Pattern\+\_\+stitch\+Polygon (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$}]{p,  }\item[{\mbox{\hyperlink{embroidery_8h_a2d6988a5f4ba24d26c7eff65dbc9d029}{Emb\+Polygon}}}]{polygon,  }\item[{int}]{thread\+\_\+index,  }\item[{int}]{style }\end{DoxyParamCaption})}

{\itshape p} {\itshape rect} {\itshape thread\+\_\+index} {\itshape style} 

\begin{DoxyRefDesc}{Todo}
\item[\mbox{\hyperlink{todo__todo000223}{Todo}}]finish stitch polygon \end{DoxyRefDesc}
\mbox{\Hypertarget{fill_8c_a9ae9d5d7dfbb2ab361dc37970b7eb2f2}\label{fill_8c_a9ae9d5d7dfbb2ab361dc37970b7eb2f2}} 
\index{fill.c@{fill.c}!embPattern\_stitchPolyline@{embPattern\_stitchPolyline}}
\index{embPattern\_stitchPolyline@{embPattern\_stitchPolyline}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{embPattern\_stitchPolyline()}{embPattern\_stitchPolyline()}}
{\footnotesize\ttfamily void emb\+Pattern\+\_\+stitch\+Polyline (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$}]{p,  }\item[{\mbox{\hyperlink{embroidery_8h_ab5563c868d8f8174d5be764808a647dd}{Emb\+Polyline}}}]{polyline,  }\item[{int}]{thread\+\_\+index,  }\item[{int}]{style }\end{DoxyParamCaption})}

{\itshape p} {\itshape rect} {\itshape thread\+\_\+index} {\itshape style} 

\begin{DoxyRefDesc}{Todo}
\item[\mbox{\hyperlink{todo__todo000224}{Todo}}]finish stitch polyline \end{DoxyRefDesc}
\mbox{\Hypertarget{fill_8c_ae38ddde615726bba5070a6b17ce6d018}\label{fill_8c_ae38ddde615726bba5070a6b17ce6d018}} 
\index{fill.c@{fill.c}!embPattern\_stitchRect@{embPattern\_stitchRect}}
\index{embPattern\_stitchRect@{embPattern\_stitchRect}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{embPattern\_stitchRect()}{embPattern\_stitchRect()}}
{\footnotesize\ttfamily void emb\+Pattern\+\_\+stitch\+Rect (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$}]{p,  }\item[{\mbox{\hyperlink{embroidery_8h_ac2f33b151fc40a0da3b14379aa0ec653}{Emb\+Rect}}}]{rect,  }\item[{int}]{thread\+\_\+index,  }\item[{int}]{style }\end{DoxyParamCaption})}

{\itshape p} {\itshape rect} {\itshape thread\+\_\+index} {\itshape style} 

Here we just stitch the rectangle in the direction of it\textquotesingle{}s longer side. \mbox{\Hypertarget{fill_8c_a908f6c41318183bcfceebdd9b646dc90}\label{fill_8c_a908f6c41318183bcfceebdd9b646dc90}} 
\index{fill.c@{fill.c}!embPattern\_stitchText@{embPattern\_stitchText}}
\index{embPattern\_stitchText@{embPattern\_stitchText}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{embPattern\_stitchText()}{embPattern\_stitchText()}}
{\footnotesize\ttfamily void emb\+Pattern\+\_\+stitch\+Text (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$}]{p,  }\item[{\mbox{\hyperlink{embroidery_8h_ac2f33b151fc40a0da3b14379aa0ec653}{Emb\+Rect}}}]{rect,  }\item[{int}]{thread\+\_\+index,  }\item[{int}]{style }\end{DoxyParamCaption})}

{\itshape p} {\itshape rect} {\itshape thread\+\_\+index} {\itshape style} \mbox{\Hypertarget{fill_8c_accb8d958755abb87ae8fe5cb64241c5b}\label{fill_8c_accb8d958755abb87ae8fe5cb64241c5b}} 
\index{fill.c@{fill.c}!embPolygon\_reduceByDistance@{embPolygon\_reduceByDistance}}
\index{embPolygon\_reduceByDistance@{embPolygon\_reduceByDistance}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{embPolygon\_reduceByDistance()}{embPolygon\_reduceByDistance()}}
{\footnotesize\ttfamily void emb\+Polygon\+\_\+reduce\+By\+Distance (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery_8h_aebe8b1561a59d167cfe6613863a671ca}{Emb\+Array}} $\ast$}]{vertices,  }\item[{\mbox{\hyperlink{embroidery_8h_aebe8b1561a59d167cfe6613863a671ca}{Emb\+Array}} $\ast$}]{simplified,  }\item[{float}]{distance }\end{DoxyParamCaption})}

{\itshape vertices} {\itshape simplified} {\itshape distance} 

Reduces the polygon by distance.

This is a non-\/destructive function, so the caller is responsible for freeing \char`\"{}vertices\char`\"{} if they choose to keep \char`\"{}simplified\char`\"{}. \mbox{\Hypertarget{fill_8c_aa25158aa39b36f6981756295d6601910}\label{fill_8c_aa25158aa39b36f6981756295d6601910}} 
\index{fill.c@{fill.c}!embPolygon\_reduceByNth@{embPolygon\_reduceByNth}}
\index{embPolygon\_reduceByNth@{embPolygon\_reduceByNth}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{embPolygon\_reduceByNth()}{embPolygon\_reduceByNth()}}
{\footnotesize\ttfamily void emb\+Polygon\+\_\+reduce\+By\+Nth (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery_8h_aebe8b1561a59d167cfe6613863a671ca}{Emb\+Array}} $\ast$}]{vertices,  }\item[{\mbox{\hyperlink{embroidery_8h_aebe8b1561a59d167cfe6613863a671ca}{Emb\+Array}} $\ast$}]{out,  }\item[{int}]{nth }\end{DoxyParamCaption})}

{\itshape vertices} {\itshape out} {\itshape nth} 

Reduces the polygon by removing the Nth vertex in the vertices list. This is a non-\/destructive function, so the caller is responsible for freeing vertices if they choose to keep out. \mbox{\Hypertarget{fill_8c_ad02b5d945eacff708d2bf084c40044d8}\label{fill_8c_ad02b5d945eacff708d2bf084c40044d8}} 
\index{fill.c@{fill.c}!generate\_dragon\_curve@{generate\_dragon\_curve}}
\index{generate\_dragon\_curve@{generate\_dragon\_curve}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{generate\_dragon\_curve()}{generate\_dragon\_curve()}}
{\footnotesize\ttfamily void generate\+\_\+dragon\+\_\+curve (\begin{DoxyParamCaption}\item[{char $\ast$}]{state,  }\item[{int}]{iterations }\end{DoxyParamCaption})}

{\itshape state} {\itshape iterations} 

using the \char`\"{}paper folding\char`\"{} method \begin{DoxyRefDesc}{Todo}
\item[\mbox{\hyperlink{todo__todo000220}{Todo}}]find citation for paper folding method \end{DoxyRefDesc}
\mbox{\Hypertarget{fill_8c_a5d43a4168ef00fcb9221321b4508c8c5}\label{fill_8c_a5d43a4168ef00fcb9221321b4508c8c5}} 
\index{fill.c@{fill.c}!greedy\_algorithm@{greedy\_algorithm}}
\index{greedy\_algorithm@{greedy\_algorithm}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{greedy\_algorithm()}{greedy\_algorithm()}}
{\footnotesize\ttfamily static void greedy\+\_\+algorithm (\begin{DoxyParamCaption}\item[{int $\ast$}]{points,  }\item[{int}]{n\+\_\+points,  }\item[{int}]{width,  }\item[{\mbox{\hyperlink{embroidery_8h_a2082be9aabfb541dff1825c4ca6a05cd}{Emb\+Real}}}]{bias }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}

{\itshape points} {\itshape n\+\_\+points} {\itshape width} {\itshape bias} \hypertarget{fill_8c_autotoc_md44}{}\doxyparagraph{Greedy Algorithm}\label{fill_8c_autotoc_md44}
For each point in the list find the shortest distance to any possible neighbour, then perform a swap to make that neighbour the next item in the list.

To make the stitches lie more on one axis than the other bias the distance operator to prefer horizontal direction. \mbox{\Hypertarget{fill_8c_a2f0cd5118998e9310252de0bd11c6fb2}\label{fill_8c_a2f0cd5118998e9310252de0bd11c6fb2}} 
\index{fill.c@{fill.c}!hilbert\_curve@{hilbert\_curve}}
\index{hilbert\_curve@{hilbert\_curve}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{hilbert\_curve()}{hilbert\_curve()}}
{\footnotesize\ttfamily int hilbert\+\_\+curve (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$}]{pattern,  }\item[{int}]{iterations }\end{DoxyParamCaption})}

{\itshape pattern} {\itshape iterations} 

\href{https://en.wikipedia.org/wiki/Hilbert_curve}{\texttt{ https\+://en.\+wikipedia.\+org/wiki/\+Hilbert\+\_\+curve}}

Using the Lindenmayer System, so we can save work across different functions. \mbox{\Hypertarget{fill_8c_a0fd47c53d468e3e5590e096495acac79}\label{fill_8c_a0fd47c53d468e3e5590e096495acac79}} 
\index{fill.c@{fill.c}!join\_short\_stitches@{join\_short\_stitches}}
\index{join\_short\_stitches@{join\_short\_stitches}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{join\_short\_stitches()}{join\_short\_stitches()}}
{\footnotesize\ttfamily static void join\+\_\+short\+\_\+stitches (\begin{DoxyParamCaption}\item[{int $\ast$}]{points,  }\item[{int $\ast$}]{n\+\_\+points,  }\item[{int}]{width,  }\item[{int}]{tolerence }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}

{\itshape points} {\itshape n\+\_\+points} {\itshape width} {\itshape tolerence} 

Remove points that lie in the middle of two short stitches that could be one longer stitch. Repeat until none are found. \mbox{\Hypertarget{fill_8c_af27a83a237ef6302cbfb5af534229e10}\label{fill_8c_af27a83a237ef6302cbfb5af534229e10}} 
\index{fill.c@{fill.c}!lindenmayer\_system@{lindenmayer\_system}}
\index{lindenmayer\_system@{lindenmayer\_system}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{lindenmayer\_system()}{lindenmayer\_system()}}
{\footnotesize\ttfamily int lindenmayer\+\_\+system (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery_8h_a914404401c03a6bf0dac814661ba370c}{L\+\_\+system}}}]{L,  }\item[{char $\ast$}]{state,  }\item[{int}]{iterations,  }\item[{int}]{complete }\end{DoxyParamCaption})}

{\itshape L} {\itshape state} {\itshape iterations} {\itshape complete} \begin{DoxyReturn}{Returns}
int
\end{DoxyReturn}
This is a slow generation algorithm. \mbox{\Hypertarget{fill_8c_af65a5f7a682322a9588066dfc9d3e10d}\label{fill_8c_af65a5f7a682322a9588066dfc9d3e10d}} 
\index{fill.c@{fill.c}!save\_points\_to\_pattern@{save\_points\_to\_pattern}}
\index{save\_points\_to\_pattern@{save\_points\_to\_pattern}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{save\_points\_to\_pattern()}{save\_points\_to\_pattern()}}
{\footnotesize\ttfamily static void save\+\_\+points\+\_\+to\+\_\+pattern (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$}]{pattern,  }\item[{int $\ast$}]{points,  }\item[{int}]{n\+\_\+points,  }\item[{\mbox{\hyperlink{embroidery_8h_a2082be9aabfb541dff1825c4ca6a05cd}{Emb\+Real}}}]{scale,  }\item[{int}]{width,  }\item[{int}]{height }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}

{\itshape pattern} {\itshape points} {\itshape n\+\_\+points} {\itshape scale} {\itshape width} {\itshape height} \mbox{\Hypertarget{fill_8c_adc8683886c723530102d2b75f14b6dbd}\label{fill_8c_adc8683886c723530102d2b75f14b6dbd}} 
\index{fill.c@{fill.c}!threshold\_method@{threshold\_method}}
\index{threshold\_method@{threshold\_method}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{threshold\_method()}{threshold\_method()}}
{\footnotesize\ttfamily static int $\ast$ threshold\+\_\+method (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery_8h_a907d23c2268eff84b7c5146b2add1bb4}{Emb\+Image}} $\ast$}]{image,  }\item[{int $\ast$}]{n\+\_\+points,  }\item[{int}]{subsample\+\_\+width,  }\item[{int}]{subsample\+\_\+height,  }\item[{int}]{threshold }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}

{\itshape image} {\itshape n\+\_\+points} {\itshape subsample\+\_\+width} {\itshape subsample\+\_\+height} {\itshape threshold} \begin{DoxyReturn}{Returns}
int$\ast$
\end{DoxyReturn}
Identify darker pixels to put stitches in. 

\doxysubsubsection{Variable Documentation}
\mbox{\Hypertarget{fill_8c_a6e10b231de6baafee918b26f004d7327}\label{fill_8c_a6e10b231de6baafee918b26f004d7327}} 
\index{fill.c@{fill.c}!hilbert\_curve\_l\_system@{hilbert\_curve\_l\_system}}
\index{hilbert\_curve\_l\_system@{hilbert\_curve\_l\_system}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{hilbert\_curve\_l\_system}{hilbert\_curve\_l\_system}}
{\footnotesize\ttfamily \mbox{\hyperlink{embroidery_8h_a914404401c03a6bf0dac814661ba370c}{L\+\_\+system}} hilbert\+\_\+curve\+\_\+l\+\_\+system}

{\bfseries Initial value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{= \{}
\DoxyCodeLine{    \textcolor{charliteral}{'A'}, \textcolor{stringliteral}{"{}AB"{}}, \textcolor{stringliteral}{"{}F+-\/"{}}, (\textcolor{keywordtype}{char}**)\mbox{\hyperlink{fill_8c_add6424b0861a4e44ac11fc4cbf99d1d1}{rules}}}
\DoxyCodeLine{\}}

\end{DoxyCode}
\mbox{\Hypertarget{fill_8c_add6424b0861a4e44ac11fc4cbf99d1d1}\label{fill_8c_add6424b0861a4e44ac11fc4cbf99d1d1}} 
\index{fill.c@{fill.c}!rules@{rules}}
\index{rules@{rules}!fill.c@{fill.c}}
\doxyparagraph{\texorpdfstring{rules}{rules}}
{\footnotesize\ttfamily const char$\ast$ rules\mbox{[}$\,$\mbox{]} = \{\char`\"{}+BF-\/AFA-\/FB+\char`\"{}, \char`\"{}-\/AF+BFB+FA-\/\char`\"{}\}}

